<template>
  <div>
    <!--表格渲染-->
    <el-table ref="table" :data="cruddata" style="width: 100%" border>
      <el-table-column type="index" width="55" label="序号" />
      <!-- <el-table-column
        :show-overflow-tooltip="true"
        prop="address"
        label="投币地址"
      /> -->
      <el-table-column
        :show-overflow-tooltip="true"
        prop="inDay"
        label="投入周期"
      />
      <el-table-column
        :show-overflow-tooltip="true"
        prop="amount"
        label="投入数量（USDT）"
      />
      <el-table-column
        :show-overflow-tooltip="true"
        prop="profitAmount"
        label="收益"
      />
      <el-table-column
        :show-overflow-tooltip="true"
        prop="endTime"
        label="结算时间"
      >
        <template slot-scope="scope">
          <div>
            {{ $moment(scope.row.endTime).format("YYYY-MM-DD HH:mm:ss") }}
          </div>
        </template>
      </el-table-column>
    </el-table>
    <!--分页组件-->
    <pagination
      :total="total"
      :page="params.page"
      :limit="params.pageSize"
      @pagination="pagination"
    />
  </div>
</template>

<script>
// import pagination from '@crud/Pagination'
import pagination from '@/components/Pagination'
import { accountAsset } from '@/api/customer'
export default {
  name: 'AccountAsset',
  components: { pagination },
  props: ['userId', 'address'],
  data() {
    return {
      params: {
        page: 1,
        pageSize: 10
      },
      cruddata: [],
      total: 0
    }
  },
  created() {
    this.getList()
  },
  methods: {
    pagination(data) {
      this.params.page = data.page
      this.params.pageSize = data.limit
      this.getList()
    },
    getList() {
      accountAsset({
        id: this.userId,
        type: 2,
        page: this.params.page,
        size: this.params.pageSize
      }).then((res) => {
        if (res.code == 0) {
          this.cruddata = res.data.records
          this.total = +res.data.total
        } else {
          this.$message.error(res.message)
        }
      })
    }
  }
}
</script>
